/* Translate position of GoCart
* Yudong Yi
* Desc: Will let GoCart Go straight.
* 
*/
#include "StdAfx.h"
#include "AnimationTranslateGoCart.h"
#include "math.h"
#define M_PI  std::atan(1.0)*4
CAnimationTranslateGoCart::CAnimationTranslateGoCart(void)
{
	m_time = 0;
	m_PreX=0;
	m_PreZ=0;
}

CAnimationTranslateGoCart::~CAnimationTranslateGoCart(void)
{
}
void CAnimationTranslateGoCart::Update(){
	m_time++;
	m_time=m_time%60;
	m_PreX = m_node->GetX();
	m_PreZ = m_node->GetZ();

	if(m_time<20)
	{
		m_node->SetX(m_PreX+2);
	}
	else if(m_time<30)
	{
		m_node->SetX((48+10 * sin((M_PI/10)*(m_time%20))));
		m_node->SetZ((-10+10 * cos((M_PI/10)*(m_time%20))));
	}
	else if(m_time<50)
	{
		m_node->SetX(m_PreX-2);
	}
	else if(m_time<60)
	{
		m_node->SetX((8+10 * sin((M_PI/10)*(m_time%20))));
		m_node->SetZ((-9+10 * cos((M_PI/10)*(m_time%20))));
	}
}
